package com.app.repository.impl;

import com.app.model.main.Favorites;
import com.app.repository.interfaces.FavoritesMapper;
import com.app.support.dao.MybatisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Lichaojie on 2017/7/14. It's a beautiful day.
 */
@Repository
public class FavoritesMapperImpl implements FavoritesMapper {

    final String namespace = "com.app.dao.main.FavoritesMapper";

    @Autowired
    private MybatisDao mybatisDao;

    @Override
    public int deleteByPrimaryKey(Long id){
        return mybatisDao.delete(namespace,".deleteByPrimaryKey",id);
    }

    @Override
    public int insert(Favorites record){
        return mybatisDao.insert(namespace,".insert",record);
    }

    @Override
    public int insertSelective(Favorites record){
        return mybatisDao.insert(namespace, ".insertSelective", record);
    }

    @Override
    public Favorites selectByPrimaryKey(Long id){
        return mybatisDao.get(namespace, ".selectByPrimaryKey", id);
    }

    @Override
    public int updateByPrimaryKeySelective(Favorites record){
        return mybatisDao.update(namespace, ".updateByPrimaryKeySelective", record);
    }

    @Override
    public int updateByPrimaryKey(Favorites record){
        return mybatisDao.update(namespace, ".updateByPrimaryKey", record);
    }

    @Override
    public List<Favorites> selectByUserId(long userId){
        return mybatisDao.getList(namespace,".selectByUserId",userId);
    }

    @Override
    public Favorites selectByUserIdAndName(long userId, String name){
        Map<String,Object> map = new HashMap();
        map.put("userId",userId);
        map.put("name",name);
        return mybatisDao.get(namespace,".selectByUserIdAndName",map);
    }
}
